<!DOCTYPE html>
<html lang="en">
<head>
<base href="${contextPath}/" />
    <meta charset="utf-8">
    <title>上传学生资料</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
    <meta name="author" content="Muhammad Usman">

    <!-- The styles -->
    <link id="bs-css" href="css/bootstrap-cerulean.min.css" rel="stylesheet">

    <link href="css/charisma-app.css" rel="stylesheet">
    <link href='bower_components/fullcalendar/dist/fullcalendar.css' rel='stylesheet'>
    <link href='bower_components/fullcalendar/dist/fullcalendar.print.css' rel='stylesheet' media='print'>
    <link href='bower_components/chosen/chosen.min.css' rel='stylesheet'>
    <link href='bower_components/colorbox/example3/colorbox.css' rel='stylesheet'>
    <link href='bower_components/responsive-tables/responsive-tables.css' rel='stylesheet'>
    <link href='bower_components/bootstrap-tour/build/css/bootstrap-tour.min.css' rel='stylesheet'>
    <link href='css/jquery.noty.css' rel='stylesheet'>
    <link href='css/noty_theme_default.css' rel='stylesheet'>
    <link href='css/elfinder.min.css' rel='stylesheet'>
    <link href='css/elfinder.theme.css' rel='stylesheet'>
    <link href='css/jquery.iphone.toggle.css' rel='stylesheet'>
    <link href='css/uploadify.css' rel='stylesheet'>
    <link href='css/animate.min.css' rel='stylesheet'>

    <!-- jQuery -->
    <script src="bower_components/jquery/jquery.min.js"></script>

    <!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- The fav icon -->
    <link rel="shortcut icon" href="img/favicon.ico">

</head>

<body>
    <!-- topbar starts -->
	<#include "commonPage/top.ftl">
	<!-- topbar ends -->
	<div class="ch-container">
		<div class="row">

			<!-- left menu starts -->
			<#include "commonPage/left.ftl">
			<!--/span-->
			<!-- left menu ends -->

        <div id="content" class="col-lg-10 col-sm-10">
            <!-- content starts -->

            <!--/学生基本信息显示-->
    <div class="row">
    <div class="box col-md-12">
    <div class="box-inner">
    <div class="box-header well" data-original-title="">
        <h2><i class="glyphicon glyphicon-user"></i>导入学生学期资料</h2>
    </div>
    <div class="box-content">
	
    <table class="table table-striped table-bordered bootstrap-datatable datatable responsive">
	<form id="uploadForm" action="${contextPath}/upload/termDataLoad" method="post" enctype="multipart/form-data">
        <div class="form-group has-warning col-md-4">
            
            <label class="control-label" for="inputWarning1">请选择日期</label> 
            <div class="controls">						
			学年：<select name="term" id="term">
						<option value="${year-1!}-${year!}-1">${year-1!}-${year!}-1</option>
						<option value="${year-1!}-${year!}-2">${year-1!}-${year!}-2</option>
						<option value="${year!}-${year+1!}-1">${year!}-${year+1!}-1</option>
						<option value="${year!}-${year+1!}-2">${year!}-${year+1!}-2</option>
					</select>
			<br>
			<br> 
		<br>    
		    <a href="commonPage/stuDetail.xls" style="color:red;">点击下载模板</a>  
		    <br> 
		    <br>        
            <input type="file" id="excelFile" name="excel"/>
            <br><br>
           <!--  <progress id="progressBar" value="0" max="100"> </progress>
            <span id="percentage"></span> -->
			<button type="button" onclick="javascript:tijiao();">提交</button>

        </div>
        </FORM>
    </table>
    
    </div>
    </div>
    </div>
    <!--/span-->

    </div><!--/row-->



    <!-- content ends -->
    </div><!--/#content.col-md-0-->
</div><!--/fluid-row-->

    <!-- Ad, you can remove it -->

    <!-- Ad ends -->

    <hr>





</div><!--/.fluid-container-->

<div id="fugai" style="color:white;display:none;height:100%; width:100%; text-align:center ;position:fixed; _position:absolute; top:0; z-index:1000;opacity:0.3; filter: alpha(opacity=30); background-color:#000; ">
	<img style="vertical-align:middle;margin:200px;" src="images/ajax-loader-7.gif"  />正在上传，请稍等...
</div> 

<!-- external javascript -->

<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

<!-- library for cookie management -->
<script src="js/jquery.cookie.js"></script>
<!-- calender plugin -->
<script src='bower_components/moment/min/moment.min.js'></script>
<script src='bower_components/fullcalendar/dist/fullcalendar.min.js'></script>
<!-- data table plugin -->
<script src='js/jquery.dataTables.min.js'></script>

<!-- select or dropdown enhancer -->
<script src="bower_components/chosen/chosen.jquery.min.js"></script>
<!-- plugin for gallery image view -->
<script src="bower_components/colorbox/jquery.colorbox-min.js"></script>
<!-- notification plugin -->
<script src="js/jquery.noty.js"></script>
<!-- library for making tables responsive -->
<script src="bower_components/responsive-tables/responsive-tables.js"></script>
<!-- tour plugin -->
<script src="bower_components/bootstrap-tour/build/js/bootstrap-tour.min.js"></script>
<!-- star rating plugin -->
<script src="js/jquery.raty.min.js"></script>
<!-- for iOS style toggle switch -->
<script src="js/jquery.iphone.toggle.js"></script>
<!-- autogrowing textarea plugin -->
<script src="js/jquery.autogrow-textarea.js"></script>
<!-- multiple file upload plugin -->
<script src="js/jquery.uploadify-3.1.min.js"></script>
<!-- history.js for cross-browser state change on ajax -->
<script src="js/jquery.history.js"></script>
<!-- application script for Charisma demo -->
<script src="js/charisma.js"></script>
<script type="text/javascript">
function tijiao(){
	var term = $("#term option:selected").val();
	var excelFile = $("#excelFile").val();
	if(term==''||term==null){
		alert("请选择学期");
	}else{
		if(excelFile==null||excelFile=="")
			{
			alert("请上传数据");
			}
		else
			{
			var fileObj = document.getElementById("excelFile").files[0]; // 获取文件对象

	        var FileController = "upload/termDataLoad";                    // 接收上传文件的后台地址 

	        // FormData 对象
	        var form = new FormData();
	        form.append("term", term);                        // 可以增加表单数据
	        form.append("excel", fileObj);                           // 文件对象

	        // XMLHttpRequest 对象

	        var xhr = new XMLHttpRequest();
	        xhr.open("post", FileController, true);
	        xhr.onload = function () {
	        	$("#fugai").hide();
	        	alert(xhr.responseText);
	        };
	      /*   xhr.upload.addEventListener("progress", progressFunction, false); */

	          xhr.send(form);
	          $("#fugai").show();
			}
		
	}	

}

</script>

</body>
</html>
